const {
    Mysql
} = require('../tools/utils');
module.exports = async ctx => {
    let {
        uid
    } = ctx.query;
    let sql = `SELECT * FROM intergal WHERE uid=${uid}`;
    try {
        let res = await Mysql(sql);
        if (res.length && Number(res[0].score) > 50) {
            // let sql2 = `UPDATE intergal SET score=score-50 WHERE uid = ${uid}`;
            // let sql3 = 
            try {
                // await Mysql(sql2);
                ctx.state.data = {
                    code: '001',
                    msg: 'مۇۋەپپەقىيەتلىك بولدى',
                    icon: 'success'
                };
            } catch (error) {
                ctx.state.data = {
                    code: '002',
                    msg: 'خاتالىق كۆرۈلدى',
                }
            }
        } else {
            ctx.state.data = {
                code: '001',
                msg: 'جۇغلانمىڭىز يەتمىدى',
                icon: 'warning'
            }
        }
    } catch (error) {
        ctx.state.data = {
            code: '002',
            msg: 'خاتالىق كۆرۈلدى'
        }
    }
}